package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.DataApplication;
import com.ruoyi.system.service.IDataApplicationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 试用申请管理Controller
 * 
 * @author hak
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/application")
public class DataApplicationController extends BaseController
{
    @Autowired
    private IDataApplicationService dataApplicationService;

    /**
     * 查询试用申请管理列表
     */
    @RequiresPermissions("system:application:list")
    @GetMapping("/list")
    public TableDataInfo list(DataApplication dataApplication)
    {
        startPage();
        List<DataApplication> list = dataApplicationService.selectDataApplicationList(dataApplication);
        return getDataTable(list);
    }

    /**
     * 导出试用申请管理列表
     */
    @RequiresPermissions("system:application:export")
    @Log(title = "试用申请管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataApplication dataApplication)
    {
        List<DataApplication> list = dataApplicationService.selectDataApplicationList(dataApplication);
        ExcelUtil<DataApplication> util = new ExcelUtil<DataApplication>(DataApplication.class);
        util.exportExcel(response, list, "试用申请管理数据");
    }

    /**
     * 获取试用申请管理详细信息
     */
    @RequiresPermissions("system:application:query")
    @GetMapping(value = "/{applicationId}")
    public AjaxResult getInfo(@PathVariable("applicationId") Long applicationId)
    {
        return success(dataApplicationService.selectDataApplicationByApplicationId(applicationId));
    }

    /**
     * 新增试用申请管理
     */
    @RequiresPermissions("system:application:add")
    @Log(title = "试用申请管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataApplication dataApplication)
    {
        return toAjax(dataApplicationService.insertDataApplication(dataApplication));
    }

    /**
     * 修改试用申请管理
     */
    @RequiresPermissions("system:application:edit")
    @Log(title = "试用申请管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataApplication dataApplication)
    {
        return toAjax(dataApplicationService.updateDataApplication(dataApplication));
    }

    /**
     * 删除试用申请管理
     */
    @RequiresPermissions("system:application:remove")
    @Log(title = "试用申请管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applicationIds}")
    public AjaxResult remove(@PathVariable Long[] applicationIds)
    {
        return toAjax(dataApplicationService.deleteDataApplicationByApplicationIds(applicationIds));
    }
}
